#include "qabstractundocommand.h"

#include "qcommandobject.h"

using namespace CORELIB;

QAbstractUndoCommand::QAbstractUndoCommand(const QMap<QString, QVariant> &param, QUndoCommand *parent):
    QUndoCommand(parent),
    m_object(new QCommandObject())
{
    QMapIterator<QString,QVariant> it(param);
    while(it.hasNext())
    {
        it.next();
        m_object->setProperty(it.key().toLocal8Bit(),it.value());
    }
}

QAbstractUndoCommand::~QAbstractUndoCommand()
{
    delete m_object;
}

void QAbstractUndoCommand::redo()
{
    m_object->emit_redo();
    QUndoCommand::redo();
}

void QAbstractUndoCommand::undo()
{
    m_object->emit_undo();
    QUndoCommand::undo();
}

QCommandObject* QAbstractUndoCommand::object()
{
    return m_object;
}
